Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 4b5e27a5e22620440cd1ae26e749d34c16fe9806


Parents : dcb0a18
Author : Mark Qvist <mark@unsigned.io>
Date : 2024-09-06T20:34:45+02:00

Updated examples

Changes

1 files changed, 9 insertions(+), 7 deletions(-)


Diff

diff --git a/docs/example_receiver.py b/docs/example_receiver.py
index 02ea0c3..8effd3e 100644
--- a/docs/example_receiver.py
+++ b/docs/example_receiver.py
@@ -2,6 +2,9 @@ import RNS
import LXMF
import time
+required_stamp_cost = 8
+enforce_stamps = False
+
def delivery_callback(message):
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(message.timestamp))
signature_string = "Signature is invalid, reason undetermined"
@@ -13,11 +16,10 @@ def delivery_callback(message):
if message.unverified_reason == LXMF.LXMessage.SOURCE_UNKNOWN:
signature_string = "Cannot verify, source is unknown"
- required_stamp_cost = 12
- if message.validate_stamp(required_stamp_cost):
- stamp_string = "Valid"
+ if message.stamp_valid:
+ stamp_string = "Validated"
else:
- stamp_string = "Not valid"
+ stamp_string = "Invalid"
RNS.log("\t+--- LXMF Delivery ---------------------------------------------")
RNS.log("\t| Source hash : "+RNS.prettyhexrep(message.source_hash))
@@ -35,9 +37,9 @@ def delivery_callback(message):
r = RNS.Reticulum()
-router = LXMF.LXMRouter(storagepath="./tmp1")
+router = LXMF.LXMRouter(storagepath="./tmp1", enforce_stamps=enforce_stamps)
identity = RNS.Identity()
-my_lxmf_destination = router.register_delivery_identity(identity)
+my_lxmf_destination = router.register_delivery_identity(identity, stamp_cost=required_stamp_cost)
router.register_delivery_callback(delivery_callback)
RNS.log("Ready to receive on: "+RNS.prettyhexrep(my_lxmf_destination.hash))
@@ -54,7 +56,7 @@ RNS.log("Ready to receive on: "+RNS.prettyhexrep(my_lxmf_destination.hash))
while True:
input()
RNS.log("Announcing lxmf.delivery destination...")
- my_lxmf_destination.announce()
+ router.announce(my_lxmf_destination.hash)
# input()
# RNS.log("Requesting messages from propagation node...")


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────